package com.itcat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcat.mysql.pojo.CmsPrefrenceAreaProductRelation;
import com.itcat.mysql.pojo.PmsMemberPrice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author 小心触碰的电脑
* @description 针对表【cms_prefrence_area_product_relation(优选专区和产品关系表)】的数据库操作Mapper
* @createDate 2022-04-03 16:11:50
* @Entity com.itcat.mysql.pojo.CmsPrefrenceAreaProductRelation
*/
@Mapper
public interface CmsPrefrenceAreaProductRelationMapper extends BaseMapper<CmsPrefrenceAreaProductRelation> {

    @Insert({"<script> " +
            "insert into cms_prefrence_area_product_relation  ( product_id, prefrence_area_id)values" +
            " <foreach collection='list' item='item' index='index' separator=',' > " +
            "( #{item.productId}, #{item.prefrenceAreaId})" +
            "</foreach>" +
            "</script>"})
    int batchInsert(@Param("list") List<CmsPrefrenceAreaProductRelation> list);

    @Update({"<script> " +
            "<foreach collection='list' item='item' index='index' separator=';'> " +
            "UPDATE cms_prefrence_area_product_relation " +
            "SET product_id = #{item.productId}, prefrence_area_id= #{item.prefrenceAreaId} " +
            "WHERE id = #{item.id} </foreach> </script>"})
    int batchUpdate(@Param("list") List<CmsPrefrenceAreaProductRelation> list);
}




